home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / science / mcalc13.zip / MCALC.C < prev    next >
C/C++ Source or Header  |  1994-02-15  |  64KB  |  2,499 lines

  1. /*
  2. Auto:        smake MCalc
  3. */
  4.  
  5.  
  6. /* $Revision Header built automatically *************** (do not edit) ************
  7. **
  8. ** ⌐ Copyright by GuntherSoft
  9. **
  10. ** File             : SnakeSYS:CPrgs/MUICalc/MCalc.c
  11. ** Created on       : Saturday, 02.10.93 02:12:50
  12. ** Created by       : Kai Iske
  13. ** Current revision : V1.0
  14. **
  15. **
  16. ** Purpose
  17. ** -------
  18. **   - This is a quite flexible, powerful Calculator made for all
  19. **     those of you, who like to calc around ;) Even for
  20. **     programmers...
  21. **
  22. ** Revision V1.0
  23. ** --------------
  24. ** created on Saturday, 02.10.93 02:12:50  by  Kai Iske.   LogMessage :
  25. **     --- Initial release ---
  26. **
  27. *********************************************************************************/
  28.  
  29.  
  30.  
  31. /**********************************************************************/
  32. /*                    Externals to Scanner/Parser                     */
  33. /**********************************************************************/
  34. extern    UWORD        PCharRead;
  35. extern    UWORD        PColumn;
  36. extern    UWORD        PError;
  37. extern    UWORD        NonDouble;
  38. extern    int        yynerrs;
  39. extern    int        yychar;
  40. extern    int        yy_init;
  41. extern    int        yy_start;
  42. extern    FILE        *yyin, *yyout;
  43. extern    void        *yy_current_buffer;
  44.  
  45.  
  46. extern UWORD        RXIntType;
  47. extern UWORD        RXIntBase;
  48. extern UWORD        RXIntSign;
  49. extern UWORD        RXIntAngle;
  50.  
  51.  
  52. /**********************************************************************/
  53. /*    Aehm, SAS 6.50 seams to open up a window just as it likes ;)    */
  54. /**********************************************************************/
  55. char __stdiowin[] = "NIL:";
  56.  
  57.  
  58.  
  59. /**********************************************************************/
  60. /*                 External variables of ARexx module                 */
  61. /**********************************************************************/
  62. extern struct MUI_Command    RXCommands[];
  63.  
  64.  
  65.  
  66.  
  67. /**********************************************************************/
  68. /*                      Routines for that module                      */
  69. /**********************************************************************/
  70. static BOOL OpenLibs(void);
  71. static void CloseLibs(void);
  72. static void SetMainWinCycle(void);
  73. static BOOL OpenMainWin(void);
  74. static void CloseMainWin(void);
  75. static ULONG    __saveds __asm InsertFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data);
  76. static ULONG    __saveds __asm DispConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data);
  77. static ULONG    __saveds __asm DispDestructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data);
  78. static ULONG    __saveds __asm DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ListStruct *Data);
  79. static void InsertText(char *NewText);
  80. static void WriteClip(char *Entry);
  81. static void HandleInputs(void);
  82.  
  83.  
  84.  
  85.  
  86. /**********************************************************************/
  87. /*                           Library-Bases                            */
  88. /**********************************************************************/
  89. extern    struct ExecBase    *SysBase;
  90.  
  91. struct    IntuitionBase    *IntuitionBase        = NULL;
  92. struct    GfxBase        *GfxBase        = NULL;
  93. struct    Library        *UtilityBase        = NULL;
  94. struct    Library        *IconBase        = NULL;
  95. struct    Library        *MUIMasterBase        = NULL;
  96. struct    Library        *MathIeeeDoubBasBase    = NULL;
  97. struct    Library        *MathIeeeDoubTransBase    = NULL;
  98. struct    Library        *IFFParseBase        = NULL;
  99.  
  100.  
  101.  
  102.  
  103. /**********************************************************************/
  104. /*                            The Objects                             */
  105. /**********************************************************************/
  106. static    struct    DiskObject    *DObject    = NULL;
  107. APTR        AppObject            = NULL;        // Is referenced through ARexx module
  108. static    APTR    MainWindow;
  109. static    APTR    InOutGroup;
  110. static    APTR    InputGroup;
  111. APTR        InputString;                    // Is referenced through ARexx module
  112. static    APTR    OutputGroup;
  113. APTR        OutputBox;                    // Is referenced through ARexx module
  114. static    APTR    FunctionCycle;
  115. static    APTR    PageObject;
  116. static    APTR    InGads[61];
  117. static    APTR    ExeObj;
  118. static    APTR    ClrObj;
  119. static    APTR    AllClrObj;
  120.  
  121. static    APTR    MainGroup;
  122. static    APTR    FuncGroup;
  123. static    APTR    InGroup;
  124.  
  125. static    APTR    PrefsWindow;
  126. static    APTR    InOutObj;
  127. static    APTR    DFuncObj;
  128. static    APTR    DInObj;
  129. static    APTR    TypeObj;
  130. static    APTR    SizeObj;
  131. static    APTR    SignObj;
  132. static    APTR    AngleObj;
  133. static    APTR    LinesObj;
  134. static    APTR    LookObj;
  135. static    APTR    ClearInObj;
  136. static    APTR    FlushObj;
  137. static    APTR    ClipObj;
  138. static    APTR    OkObj;
  139. static    APTR    SaveObj;
  140. static    APTR    CancelObj;
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. /**********************************************************************/
  148. /*                 Strings for Functions Cycle-Gadget                 */
  149. /**********************************************************************/
  150. static const char *FunctionEntries[] =
  151. {
  152.     "Mathematical set",
  153.     "Programmer`s set",
  154.     NULL
  155. };
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. /**********************************************************************/
  163. /*                      Strings for Prefs-Cycles                      */
  164. /**********************************************************************/
  165. static const char *InOutLookEntries[] =
  166. {
  167.     "Input then Output",
  168.     "Output then Input",
  169.     NULL
  170. };
  171.  
  172. static const char *TypeEntries[] =
  173. {
  174.     "Decimal",
  175.     "HexDecimal",
  176.     "Octal",
  177.     "Binary",
  178.     NULL
  179. };
  180.  
  181. static const char *SizeEntries[] =
  182. {
  183.     "8-Bit",
  184.     "16-Bit",
  185.     "32-Bit",
  186.     NULL
  187. };
  188.  
  189. static const char *SignEntries[] =
  190. {
  191.     "Signed",
  192.     "Unsigned",
  193.     NULL
  194. };
  195.  
  196. static const char *AngleEntries[] =
  197. {
  198.     "Radians",
  199.     "Degree",
  200.     NULL
  201. };
  202.  
  203. static const char *LookEntries[] =
  204. {
  205.     "Input & Output",
  206.     "Output & Input",
  207.     "Input",
  208.     "Output",
  209.     NULL
  210. };
  211.  
  212.  
  213. static const char *LookTemplates[] =
  214. {
  215.     "COL=0 DELTA=12 P=\033r MAW=100 MIW=0, COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1",
  216.     "COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1, COL=0 DELTA=12 P=\033r MAW=100 MIW=0",
  217.     "COL=0 DELTA=12 P=\033r MIW=100",
  218.     "COL=1 DELTA=12 P=\033r MIW=100"
  219. };
  220.  
  221.  
  222.  
  223. /**********************************************************************/
  224. /*                   Chars/String for window title                    */
  225. /**********************************************************************/
  226. static const char TypeChar[] =
  227. {
  228.     'D',
  229.     'H',
  230.     'O',
  231.     'B'
  232. };
  233.  
  234. static const char *BaseStr[] =
  235. {
  236.     "8",
  237.     "16",
  238.     "32"
  239. };
  240.  
  241.  
  242. static const char SignChar[] =
  243. {
  244.     'S',
  245.     'U',
  246. };
  247.  
  248.  
  249. static const char *AngleStr[] =
  250. {
  251.     "RAD",
  252.     "DEG",
  253. };
  254.  
  255.  
  256.  
  257.  
  258. /**********************************************************************/
  259. /*                          Menu-Definition                           */
  260. /**********************************************************************/
  261. static struct    NewMenu MainMenuDef[] =
  262. {
  263.     NM_TITLE, "Project", NULL, 0, NULL, NULL,
  264.     NM_ITEM, "Preferences...", "P", 0, NULL, (APTR)ID_PREFS,
  265.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  266.     NM_ITEM, "About...", "?", 0, NULL, (APTR)ID_ABOUT,
  267.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  268.     NM_ITEM, "Quit", "Q", 0, NULL, (APTR)ID_QUIT,
  269.  
  270.     NM_TITLE, "Edit", NULL, 0, NULL, NULL,
  271.     NM_ITEM, "Clear", "X", 0, NULL, (APTR)ID_CLEAR,
  272.     NM_ITEM, "All Clear", "Y", 0, NULL, (APTR)ID_ALLCLEAR,
  273.  
  274.     NM_TITLE, "History", NULL, 0, NULL, NULL,
  275.     NM_ITEM, "Pick left entry", "L", 0, NULL, (APTR)ID_PICKLEFT,
  276.     NM_ITEM, "Pick right entry", "R", 0, NULL, (APTR)ID_PICKRIGHT,
  277.     NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
  278.     NM_ITEM, "Copy left entry", "F", 0, NULL, (APTR)ID_CLIPCUTLEFT,
  279.     NM_ITEM, "Copy right entry", "G", 0, NULL, (APTR)ID_CLIPCUTRIGHT,
  280.  
  281.     NM_TITLE, "Display Bases", NULL, 0, NULL, NULL,
  282.     NM_ITEM, "Decimal", "D", CHECKIT|MENUTOGGLE, 14, (APTR)ID_DECIMAL,
  283.     NM_ITEM, "Hexadecimal", "H", CHECKIT|MENUTOGGLE, 13, (APTR)ID_HEXDECIMAL,
  284.     NM_ITEM, "Octal", "O", CHECKIT|MENUTOGGLE, 11, (APTR)ID_OCTAL,
  285.     NM_ITEM, "Binary", "B", CHECKIT|MENUTOGGLE, 7, (APTR)ID_BINARY,
  286.  
  287.     NM_TITLE, "Size", NULL, 0, NULL, NULL,
  288.     NM_ITEM, "8 Bit", "8", CHECKIT|MENUTOGGLE, 6, (APTR)ID_8BIT,
  289.     NM_ITEM, "16 Bit", "16", CHECKIT|MENUTOGGLE, 5, (APTR)ID_16BIT,
  290.     NM_ITEM, "32 Bit", "32", CHECKIT|MENUTOGGLE, 3, (APTR)ID_32BIT,
  291.  
  292.     NM_TITLE, "Sign", NULL, 0, NULL, NULL,
  293.     NM_ITEM, "Signed", "S", CHECKIT|MENUTOGGLE, 2, (APTR)ID_SIGNED,
  294.     NM_ITEM, "Unsigned", "U", CHECKIT|MENUTOGGLE, 1, (APTR)ID_UNSIGNED,
  295.  
  296.     NM_TITLE, "Angle", NULL, 0, NULL, NULL,
  297.     NM_ITEM, "Radians", "A", CHECKIT|MENUTOGGLE, 2, (APTR)ID_RAD,
  298.     NM_ITEM, "Degree", "E", CHECKIT|MENUTOGGLE, 1, (APTR)ID_DEG,
  299.  
  300.     NM_END, NULL, NULL, 0, NULL, NULL
  301. };
  302.  
  303.  
  304.  
  305.  
  306.  
  307. /**********************************************************************/
  308. /*                       Some global Variables                        */
  309. /**********************************************************************/
  310. static struct    Hook    InsertHook =             // This is our hook for the InputGadgets
  311. {
  312.     {NULL},
  313.     (APTR)InsertFunc,
  314.     NULL,
  315.     NULL
  316. };
  317.  
  318.  
  319. static struct    Hook    DispConstructHook =        // Hooks for multi-column display
  320. {
  321.     {NULL},
  322.     (APTR)DispConstructFunc,
  323.     NULL,
  324.     NULL
  325. };
  326.  
  327. static struct Hook    DispDestructHook =
  328. {
  329.     {NULL},
  330.     (APTR)DispDestructFunc,
  331.     NULL,
  332.     NULL
  333. };
  334.  
  335. static struct Hook    DispViewHook = 
  336. {
  337.     {NULL},
  338.     (APTR)DispViewFunc,
  339.     NULL,
  340.     NULL
  341. };
  342.  
  343.  
  344. char    *ParseInput;                // This has to be global, so that the scanner my find it ;)
  345. APTR    ParsePool;                // Pointer to parser`s memory pool
  346. char    Title[80];                // Title of main window
  347.  
  348.  
  349. double    Value,                    // Value being displayed and memories
  350.     XMem,
  351.     YMem,
  352.     ZMem;
  353.  
  354.  
  355. UWORD    InOutLook    = 0;                // How to order the String and ListView gadgets
  356. UWORD    NoFuncs        = FALSE;            // Display function gadgets ???
  357. UWORD    NoInput        = FALSE;            // Display input gadgets ???
  358. UWORD    IntType        = ID_DECIMAL;            // Current output format
  359. UWORD    IntBase        = ID_32BIT;            // Current conversion base
  360. UWORD    IntSign        = ID_SIGNED;            // Current ouput sign-format
  361. UWORD    IntAngle    = ID_RAD;            // Current angle format
  362. UWORD    HistLines    = 32;                // Default number of history lines
  363. UWORD    ListLook    = 0;                // Look of ListView
  364. UWORD    FlushOnExit    = FALSE;            // Flush memory on exit ???
  365. UWORD    ClearInput    = FALSE;            // Clear input string after RETURN/EXEC ???
  366. UWORD    ClipUnit    = 0;                // Number of clipboard to use
  367. UWORD    ContainsUnDec;                    // This is to signal the main program,
  368.                             // that non-decimal digits have been used
  369.  
  370.  
  371.  
  372.  
  373.  
  374. /**********************************************************************/
  375. /*                        Do the wild thing ;)                        */
  376. /**********************************************************************/
  377. void main(void)
  378. {
  379.     APTR    FlushPtr;
  380.     int    i;
  381.  
  382.         // Try to open libs
  383.  
  384.     if(OpenLibs())
  385.     {
  386.             // Try to open the main window
  387.  
  388.         if(OpenMainWin())
  389.         {
  390.                 // Display "0" in desired format
  391.  
  392.             FormatOutput(FALSE);
  393.  
  394.                 // Handle incoming inputs
  395.  
  396.             HandleInputs();
  397.         }
  398.         CloseMainWin();
  399.     }
  400.     CloseLibs();
  401.  
  402.  
  403.         // Should memory be flushed ???
  404.  
  405.     if(FlushOnExit)
  406.     {
  407.         for(i = 0; i < 10; i++)
  408.         {
  409.             if((FlushPtr = AllocMem(0x1DCD6500, MEMF_PUBLIC)))
  410.                 FreeMem(FlushPtr, 0x1DCD6500);
  411.         }
  412.     }
  413.  
  414.     exit(0);
  415. }
  416.  
  417.  
  418.  
  419.  
  420. /**********************************************************************/
  421. /*                      Open-Up needed libraries                      */
  422. /**********************************************************************/
  423. static BOOL OpenLibs(void)
  424. {
  425.     if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37)))
  426.         return(FALSE);
  427.  
  428.     if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37)))
  429.         return(FALSE);
  430.  
  431.     if(!(UtilityBase = OpenLibrary("utility.library", 37)))
  432.         return(FALSE);
  433.  
  434.     if(!(IconBase = OpenLibrary("icon.library", 37)))
  435.         return(FALSE);
  436.  
  437.     if(!(MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 37)))
  438.         return(FALSE);
  439.  
  440.     if(!(MathIeeeDoubTransBase = OpenLibrary("mathieeedoubtrans.library", 37)))
  441.         return(FALSE);
  442.  
  443.     if(!(IFFParseBase = OpenLibrary("iffparse.library", 37)))
  444.         return(FALSE);
  445.  
  446.     if(!(MUIMasterBase = OpenLibrary("muimaster.library", 0)))
  447.         return(FALSE);
  448.  
  449.     return(TRUE);
  450. }
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458. /**********************************************************************/
  459. /*                          Close used libs                           */
  460. /**********************************************************************/
  461. static void CloseLibs(void)
  462. {
  463.     if(MUIMasterBase)
  464.         CloseLibrary(MUIMasterBase);
  465.  
  466.     if(IFFParseBase)
  467.         CloseLibrary(IFFParseBase);
  468.  
  469.     if(MathIeeeDoubTransBase)
  470.         CloseLibrary(MathIeeeDoubTransBase);
  471.  
  472.     if(MathIeeeDoubBasBase)
  473.         CloseLibrary(MathIeeeDoubBasBase);
  474.  
  475.     if(IconBase)
  476.         CloseLibrary(IconBase);
  477.  
  478.     if(UtilityBase)
  479.         CloseLibrary(UtilityBase);
  480.  
  481.     if(GfxBase)
  482.         CloseLibrary((struct Library *)GfxBase);
  483.  
  484.     if(IntuitionBase)
  485.         CloseLibrary((struct Library *)IntuitionBase);
  486. }
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493. /**********************************************************************/
  494. /*                  Set Cycle Chain for main window                   */
  495. /**********************************************************************/
  496. static void SetMainWinCycle(void)
  497. {
  498.     APTR    FirstCycle,
  499.         LastCycle;
  500.     int    GadNum;
  501.  
  502.     if(!InOutLook)
  503.     {
  504.         FirstCycle    = InputString;
  505.         LastCycle    = OutputBox;
  506.     }
  507.     else
  508.     {
  509.         FirstCycle    = OutputBox;
  510.         LastCycle    = InputString;
  511.     }
  512.         // Set Cycle chanin
  513.  
  514.     GadNum    = 0;
  515.     DoMethod(MainWindow, MUIM_Window_SetCycleChain,
  516.         FirstCycle,
  517.         LastCycle,
  518.         FunctionCycle,
  519.         InGads[GadNum++],
  520.         InGads[GadNum++],
  521.         InGads[GadNum++],
  522.         InGads[GadNum++],
  523.         InGads[GadNum++],
  524.         InGads[GadNum++],
  525.         InGads[GadNum++],
  526.         InGads[GadNum++],
  527.         InGads[GadNum++],
  528.         InGads[GadNum++],
  529.         InGads[GadNum++],
  530.         InGads[GadNum++],
  531.         InGads[GadNum++],
  532.         InGads[GadNum++],
  533.         InGads[GadNum++],
  534.         InGads[GadNum++],
  535.         InGads[GadNum++],
  536.         InGads[GadNum++],
  537.         InGads[GadNum++],
  538.         InGads[GadNum++],
  539.         InGads[GadNum++],
  540.         InGads[GadNum++],
  541.         InGads[GadNum++],
  542.         InGads[GadNum++],
  543.         InGads[GadNum++],
  544.         InGads[GadNum++],
  545.         InGads[GadNum++],
  546.         InGads[GadNum++],
  547.         InGads[GadNum++],
  548.         InGads[GadNum++],
  549.         InGads[GadNum++],
  550.         InGads[GadNum++],
  551.         InGads[GadNum++],
  552.         InGads[GadNum++],
  553.         InGads[GadNum++],
  554.         InGads[GadNum++],
  555.         InGads[GadNum++],
  556.         InGads[GadNum++],
  557.         InGads[GadNum++],
  558.         InGads[GadNum++],
  559.         InGads[GadNum++],
  560.         InGads[GadNum++],
  561.         InGads[GadNum++],
  562.         InGads[GadNum++],
  563.         InGads[GadNum++],
  564.         InGads[GadNum++],
  565.         InGads[GadNum++],
  566.         InGads[GadNum++],
  567.         InGads[GadNum++],
  568.         InGads[GadNum++],
  569.         InGads[GadNum++],
  570.         InGads[GadNum++],
  571.         InGads[GadNum++],
  572.         InGads[GadNum++],
  573.         InGads[GadNum++],
  574.         InGads[GadNum++],
  575.         InGads[GadNum++],
  576.         InGads[GadNum++],
  577.         InGads[GadNum++],
  578.         InGads[GadNum++],
  579.         InGads[GadNum++],
  580.         ClrObj,
  581.         AllClrObj,
  582.         ExeObj,
  583.     NULL);
  584. }
  585.  
  586.  
  587.  
  588.  
  589. /**********************************************************************/
  590. /*                    Open the Calculator`s Window                    */
  591. /**********************************************************************/
  592. static BOOL OpenMainWin(void)
  593. {
  594.     ULONG    Dummy, GadNum = 0;
  595.  
  596.  
  597.         // The input String Requester
  598.  
  599.     InputGroup    = VGroup, Child,
  600.         InputString    =    StringObject, StringFrame,
  601.                         MUIA_String_Contents,    "0",
  602.                         MUIA_String_MaxLen,    256,
  603.                         MUIA_String_Format,    MUIV_String_Format_Right,
  604.                         MUIA_String_BufferPos,    1,
  605.                     End,
  606.     End;
  607.  
  608.  
  609.         // The Output Box
  610.  
  611.     OutputGroup    = VGroup, Child,
  612.         OutputBox    =    ListviewObject,
  613.                         MUIA_Listview_Input,        TRUE,
  614.                         MUIA_Listview_List,    ListObject, InputListFrame,
  615.                             MUIA_Background,        MUII_ListBack,
  616.                             MUIA_List_Format,        "COL=0 DELTA=8 P=\033r MAW=50 MIW=10, COL=1 DELTA=8 P=\033r MAW=50 MIW=10",
  617.                             MUIA_List_ConstructHook,    &DispConstructHook,
  618.                             MUIA_List_DestructHook,        &DispDestructHook,
  619.                             MUIA_List_DisplayHook,        &DispViewHook,
  620.                         End,
  621.                     End,
  622.     End;
  623.  
  624.  
  625.         // Create the Application window
  626.  
  627.     AppObject    = ApplicationObject,
  628.                 MUIA_Application_Title,        "MCalc",
  629.                 MUIA_Application_Version,    MUIVERS,
  630.                 MUIA_Application_Copyright,    "⌐1993 Kai Iske",
  631.                 MUIA_Application_Author,    "Kai Iske",
  632.                 MUIA_Application_Description,    "Quite powerful calculator, GiftWare",
  633.                 MUIA_Application_Base,        "MCalc",
  634.                 MUIA_Application_SingleTask,    TRUE,
  635.                 MUIA_Application_DiskObject,    DObject = GetDiskObjectNew("PROGDIR:MCalc"),
  636.                 MUIA_Application_Commands,    &RXCommands[0],
  637.                 MUIA_HelpFile,            "MCalc.guide",
  638.  
  639.             // Now head for the main window
  640.  
  641.         SubWindow, MainWindow =    WindowObject,
  642.                         MUIA_Window_Title,    "MUIProCalc "REVISION" - "REVDATE,
  643.                         MUIA_Window_ID,        'MPCM',
  644.                         MUIA_Window_SizeGadget,    TRUE,
  645.                         MUIA_Window_Menu,    &MainMenuDef,
  646.                         MUIA_HelpNode,        NODE_MAIN,
  647.  
  648.                 // Do the gadgets
  649.  
  650.             WindowContents,
  651.             MainGroup = VGroup,
  652.  
  653.                     // First of all the Input and Output Group
  654.  
  655.                 Child,
  656.                 InOutGroup = VGroup, GroupFrame,
  657.                     MUIA_HelpNode,    NODE_INOUTPUT,
  658.                 End, // Input Area
  659.  
  660.                     // Now check for the Function Gadgets
  661.  
  662.                 Child,
  663.  
  664.                 FuncGroup = VGroup, GroupFrame,
  665.                     MUIA_HelpNode, NODE_FUNCTIONS,
  666.  
  667.                     Child, ColGroup(2),
  668.  
  669.                             // The Cycle Gadget for Function keys
  670.  
  671.                         Child, KeyLabel1("Function:", 'n'),
  672.                         Child, FunctionCycle    =    CycleObject, ButtonFrame,
  673.                                             MUIA_Cycle_Active,    0,
  674.                                             MUIA_Cycle_Entries,    FunctionEntries,
  675.                                             MUIA_ControlChar,    'n',
  676.                                             MUIA_ExportID,        'FPAG',
  677.                                         End,
  678.                     End, // Cycle Gadget
  679.  
  680.                     // Function Buttons
  681.  
  682.                     Child, PageObject = PageGroup,
  683.  
  684.                         Child, ColGroup(6), MUIA_Group_SameWidth, TRUE,
  685.  
  686.                                 // First row of Functions
  687.  
  688.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  689.                                                 MUIA_Text_Contents,    "Sin",
  690.                                                 MUIA_Text_PreParse,    "\33c",
  691.                                                 MUIA_Background,    MUII_ButtonBack,
  692.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  693.                                             End,
  694.  
  695.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  696.                                                 MUIA_Text_Contents,    "Cos",
  697.                                                 MUIA_Text_PreParse,    "\33c",
  698.                                                 MUIA_Background,    MUII_ButtonBack,
  699.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  700.                                             End,
  701.  
  702.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  703.                                                 MUIA_Text_Contents,    "Tan",
  704.                                                 MUIA_Text_PreParse,    "\33c",
  705.                                                 MUIA_Background,    MUII_ButtonBack,
  706.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  707.                                             End,
  708.  
  709.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  710.                                                 MUIA_Text_Contents,    "ASin",
  711.                                                 MUIA_Text_PreParse,    "\33c",
  712.                                                 MUIA_Background,    MUII_ButtonBack,
  713.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  714.                                             End,
  715.  
  716.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  717.                                                 MUIA_Text_Contents,    "ACos",
  718.                                                 MUIA_Text_PreParse,    "\33c",
  719.                                                 MUIA_Background,    MUII_ButtonBack,
  720.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  721.                                             End,
  722.  
  723.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  724.                                                 MUIA_Text_Contents,    "ATan",
  725.                                                 MUIA_Text_PreParse,    "\33c",
  726.                                                 MUIA_Background,    MUII_ButtonBack,
  727.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  728.                                             End,
  729.  
  730.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  731.                                                 MUIA_Text_Contents,    "SinH",
  732.                                                 MUIA_Text_PreParse,    "\33c",
  733.                                                 MUIA_Background,    MUII_ButtonBack,
  734.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  735.                                             End,
  736.  
  737.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  738.                                                 MUIA_Text_Contents,    "CosH",
  739.                                                 MUIA_Text_PreParse,    "\33c",
  740.                                                 MUIA_Background,    MUII_ButtonBack,
  741.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  742.                                             End,
  743.  
  744.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  745.                                                 MUIA_Text_Contents,    "TanH",
  746.                                                 MUIA_Text_PreParse,    "\33c",
  747.                                                 MUIA_Background,    MUII_ButtonBack,
  748.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  749.                                             End,
  750.  
  751.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  752.                                                 MUIA_Text_Contents,    "Log",
  753.                                                 MUIA_Text_PreParse,    "\33c",
  754.                                                 MUIA_Background,    MUII_ButtonBack,
  755.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  756.                                             End,
  757.  
  758.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  759.                                                 MUIA_Text_Contents,    "Log10",
  760.                                                 MUIA_Text_PreParse,    "\33c",
  761.                                                 MUIA_Background,    MUII_ButtonBack,
  762.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  763.                                             End,
  764.  
  765.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  766.                                                 MUIA_Text_Contents,    "Exp",
  767.                                                 MUIA_Text_PreParse,    "\33c",
  768.                                                 MUIA_Background,    MUII_ButtonBack,
  769.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  770.                                             End,
  771.  
  772.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  773.                                                 MUIA_Text_Contents,    "^",
  774.                                                 MUIA_Text_PreParse,    "\33c",
  775.                                                 MUIA_Background,    MUII_ButtonBack,
  776.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  777.                                             End,
  778.  
  779.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  780.                                                 MUIA_Text_Contents,    "Pi",
  781.                                                 MUIA_Text_PreParse,    "\33c",
  782.                                                 MUIA_Background,    MUII_ButtonBack,
  783.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  784.                                             End,
  785.  
  786.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  787.                                                 MUIA_Text_Contents,    "Sqrt",
  788.                                                 MUIA_Text_PreParse,    "\33c",
  789.                                                 MUIA_Background,    MUII_ButtonBack,
  790.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  791.                                             End,
  792.  
  793.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  794.                                                 MUIA_Text_Contents,    "Abs",
  795.                                                 MUIA_Text_PreParse,    "\33c",
  796.                                                 MUIA_Background,    MUII_ButtonBack,
  797.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  798.                                             End,
  799.  
  800.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  801.                                                 MUIA_Text_Contents,    "Cot",
  802.                                                 MUIA_Text_PreParse,    "\33c",
  803.                                                 MUIA_Background,    MUII_ButtonBack,
  804.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  805.                                             End,
  806.  
  807.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  808.                                                 MUIA_Text_Contents,    "e",
  809.                                                 MUIA_Text_PreParse,    "\33c",
  810.                                                 MUIA_Background,    MUII_ButtonBack,
  811.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  812.                                             End,
  813.  
  814.                         End, // First Button Bank
  815.  
  816.                             // Second Button-Bank
  817.  
  818.                         Child, ColGroup(6), MUIA_Group_SameWidth, TRUE,
  819.  
  820.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  821.                                                 MUIA_Text_Contents,    "Mod",
  822.                                                 MUIA_Text_PreParse,    "\33c",
  823.                                                 MUIA_Background,    MUII_ButtonBack,
  824.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  825.                                             End,
  826.  
  827.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  828.                                                 MUIA_Text_Contents,    "And",
  829.                                                 MUIA_Text_PreParse,    "\33c",
  830.                                                 MUIA_Background,    MUII_ButtonBack,
  831.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  832.                                             End,
  833.  
  834.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  835.                                                 MUIA_Text_Contents,    "Or",
  836.                                                 MUIA_Text_PreParse,    "\33c",
  837.                                                 MUIA_Background,    MUII_ButtonBack,
  838.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  839.                                             End,
  840.  
  841.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  842.                                                 MUIA_Text_Contents,    "XOr",
  843.                                                 MUIA_Text_PreParse,    "\33c",
  844.                                                 MUIA_Background,    MUII_ButtonBack,
  845.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  846.                                             End,
  847.  
  848.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  849.                                                 MUIA_Text_Contents,    "Not",
  850.                                                 MUIA_Text_PreParse,    "\33c",
  851.                                                 MUIA_Background,    MUII_ButtonBack,
  852.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  853.                                             End,
  854.  
  855.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  856.                                                 MUIA_Text_Contents,    "Asl",
  857.                                                 MUIA_Text_PreParse,    "\33c",
  858.                                                 MUIA_Background,    MUII_ButtonBack,
  859.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  860.                                             End,
  861.  
  862.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  863.                                                 MUIA_Text_Contents,    "Asr",
  864.                                                 MUIA_Text_PreParse,    "\33c",
  865.                                                 MUIA_Background,    MUII_ButtonBack,
  866.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  867.                                             End,
  868.  
  869.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  870.                                                 MUIA_Text_Contents,    "Lsl",
  871.                                                 MUIA_Text_PreParse,    "\33c",
  872.                                                 MUIA_Background,    MUII_ButtonBack,
  873.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  874.                                             End,
  875.  
  876.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  877.                                                 MUIA_Text_Contents,    "Lsr",
  878.                                                 MUIA_Text_PreParse,    "\33c",
  879.                                                 MUIA_Background,    MUII_ButtonBack,
  880.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  881.                                             End,
  882.  
  883.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  884.                                                 MUIA_Text_Contents,    "Rol",
  885.                                                 MUIA_Text_PreParse,    "\33c",
  886.                                                 MUIA_Background,    MUII_ButtonBack,
  887.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  888.                                             End,
  889.  
  890.                             Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  891.                                                 MUIA_Text_Contents,    "Ror",
  892.                                                 MUIA_Text_PreParse,    "\33c",
  893.                                                 MUIA_Background,    MUII_ButtonBack,
  894.                                                 MUIA_InputMode,        MUIV_InputMode_RelVerify,
  895.                                             End,
  896.                             Child, HSpace(0),
  897.                         End, // Second Button Bank
  898.                     End, // Page-Group
  899.                 End, // Second Area
  900.  
  901.                 Child,
  902.                 InGroup = VGroup, GroupFrame,
  903.                     MUIA_HelpNode,    NODE_INPUTS,
  904.  
  905.                     Child, ColGroup(7), MUIA_Group_SameWidth, TRUE,
  906.  
  907.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  908.                                         MUIA_Text_Contents,    "A",
  909.                                         MUIA_Text_PreParse,    "\33c",
  910.                                         MUIA_Background,    MUII_ButtonBack,
  911.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  912.                                     End,
  913.  
  914.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  915.                                         MUIA_Text_Contents,    "B",
  916.                                         MUIA_Text_PreParse,    "\33c",
  917.                                         MUIA_Background,    MUII_ButtonBack,
  918.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  919.                                     End,
  920.  
  921.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  922.                                         MUIA_Text_Contents,    "C",
  923.                                         MUIA_Text_PreParse,    "\33c",
  924.                                         MUIA_Background,    MUII_ButtonBack,
  925.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  926.                                     End,
  927.  
  928.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  929.                                         MUIA_Text_Contents,    "D",
  930.                                         MUIA_Text_PreParse,    "\33c",
  931.                                         MUIA_Background,    MUII_ButtonBack,
  932.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  933.                                     End,
  934.  
  935.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  936.                                         MUIA_Text_Contents,    "E",
  937.                                         MUIA_Text_PreParse,    "\33c",
  938.                                         MUIA_Background,    MUII_ButtonBack,
  939.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  940.                                     End,
  941.  
  942.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  943.                                         MUIA_Text_Contents,    "$",
  944.                                         MUIA_Text_PreParse,    "\33c",
  945.                                         MUIA_Background,    MUII_ButtonBack,
  946.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  947.                                     End,
  948.  
  949.                         Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  950.                                             MUIA_Text_Contents,    "0x",
  951.                                             MUIA_Text_PreParse,    "\33c",
  952.                                             MUIA_Background,    MUII_ButtonBack,
  953.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  954.                                         End,
  955.  
  956.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  957.                                         MUIA_Text_Contents,    "7",
  958.                                         MUIA_Text_PreParse,    "\33c",
  959.                                         MUIA_Background,    MUII_ButtonBack,
  960.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  961.                                     End,
  962.  
  963.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  964.                                         MUIA_Text_Contents,    "8",
  965.                                         MUIA_Text_PreParse,    "\33c",
  966.                                         MUIA_Background,    MUII_ButtonBack,
  967.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  968.                                     End,
  969.  
  970.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  971.                                         MUIA_Text_Contents,    "9",
  972.                                         MUIA_Text_PreParse,    "\33c",
  973.                                         MUIA_Background,    MUII_ButtonBack,
  974.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  975.                                     End,
  976.  
  977.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  978.                                         MUIA_Text_Contents,    "/",
  979.                                         MUIA_Text_PreParse,    "\33c",
  980.                                         MUIA_Background,    MUII_ButtonBack,
  981.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  982.                                     End,
  983.  
  984.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  985.                                         MUIA_Text_Contents,    "F",
  986.                                         MUIA_Text_PreParse,    "\33c",
  987.                                         MUIA_Background,    MUII_ButtonBack,
  988.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  989.                                     End,
  990.  
  991.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  992.                                         MUIA_Text_Contents,    "\\",
  993.                                         MUIA_Text_PreParse,    "\33c",
  994.                                         MUIA_Background,    MUII_ButtonBack,
  995.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  996.                                     End,
  997.  
  998.                         Child, InGads[GadNum++]    =    TextObject, ButtonFrame,
  999.                                             MUIA_Text_Contents,    "!",
  1000.                                             MUIA_Text_PreParse,    "\33c",
  1001.                                             MUIA_Background,    MUII_ButtonBack,
  1002.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1003.                                         End,
  1004.  
  1005.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1006.                                         MUIA_Text_Contents,    "4",
  1007.                                         MUIA_Text_PreParse,    "\33c",
  1008.                                         MUIA_Background,    MUII_ButtonBack,
  1009.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1010.                                     End,
  1011.  
  1012.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1013.                                         MUIA_Text_Contents,    "5",
  1014.                                         MUIA_Text_PreParse,    "\33c",
  1015.                                         MUIA_Background,    MUII_ButtonBack,
  1016.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1017.                                     End,
  1018.  
  1019.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1020.                                         MUIA_Text_Contents,    "6",
  1021.                                         MUIA_Text_PreParse,    "\33c",
  1022.                                         MUIA_Background,    MUII_ButtonBack,
  1023.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1024.                                     End,
  1025.  
  1026.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1027.                                         MUIA_Text_Contents,    "*",
  1028.                                         MUIA_Text_PreParse,    "\33c",
  1029.                                         MUIA_Background,    MUII_ButtonBack,
  1030.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1031.                                     End,
  1032.  
  1033.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1034.                                         MUIA_Text_Contents,    "X",
  1035.                                         MUIA_Text_PreParse,    "\33c",
  1036.                                         MUIA_Background,    MUII_ButtonBack,
  1037.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1038.                                     End,
  1039.  
  1040.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1041.                                         MUIA_Text_Contents,    "%",
  1042.                                         MUIA_Text_PreParse,    "\33c",
  1043.                                         MUIA_Background,    MUII_ButtonBack,
  1044.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1045.                                     End,
  1046.  
  1047.                         Child, ClrObj        =    TextObject, ButtonFrame,
  1048.                                             MUIA_Text_Contents,    "CLR",
  1049.                                             MUIA_Text_PreParse,    "\33c",
  1050.                                             MUIA_Background,    MUII_ButtonBack,
  1051.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1052.                                         End,
  1053.  
  1054.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1055.                                         MUIA_Text_Contents,    "1",
  1056.                                         MUIA_Text_PreParse,    "\33c",
  1057.                                         MUIA_Background,    MUII_ButtonBack,
  1058.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1059.                                     End,
  1060.  
  1061.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1062.                                         MUIA_Text_Contents,    "2",
  1063.                                         MUIA_Text_PreParse,    "\33c",
  1064.                                         MUIA_Background,    MUII_ButtonBack,
  1065.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1066.                                     End,
  1067.  
  1068.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1069.                                         MUIA_Text_Contents,    "3",
  1070.                                         MUIA_Text_PreParse,    "\33c",
  1071.                                         MUIA_Background,    MUII_ButtonBack,
  1072.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1073.                                     End,
  1074.  
  1075.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1076.                                         MUIA_Text_Contents,    "-",
  1077.                                         MUIA_Text_PreParse,    "\33c",
  1078.                                         MUIA_Background,    MUII_ButtonBack,
  1079.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1080.                                     End,
  1081.  
  1082.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1083.                                         MUIA_Text_Contents,    "Y",
  1084.                                         MUIA_Text_PreParse,    "\33c",
  1085.                                         MUIA_Background,    MUII_ButtonBack,
  1086.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1087.                                     End,
  1088.  
  1089.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1090.                                         MUIA_Text_Contents,    "(",
  1091.                                         MUIA_Text_PreParse,    "\33c",
  1092.                                         MUIA_Background,    MUII_ButtonBack,
  1093.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1094.                                     End,
  1095.  
  1096.                         Child, AllClrObj    =    TextObject, ButtonFrame,
  1097.                                             MUIA_Text_Contents,    "ACLR",
  1098.                                             MUIA_Text_PreParse,    "\33c",
  1099.                                             MUIA_Background,    MUII_ButtonBack,
  1100.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1101.                                         End,
  1102.  
  1103.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1104.                                         MUIA_Text_Contents,    "0",
  1105.                                         MUIA_Text_PreParse,    "\33c",
  1106.                                         MUIA_Background,    MUII_ButtonBack,
  1107.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1108.                                     End,
  1109.  
  1110.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1111.                                         MUIA_Text_Contents,    ".",
  1112.                                         MUIA_Text_PreParse,    "\33c",
  1113.                                         MUIA_Background,    MUII_ButtonBack,
  1114.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1115.                                     End,
  1116.  
  1117.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1118.                                         MUIA_Text_Contents,    "=",
  1119.                                         MUIA_Text_PreParse,    "\33c",
  1120.                                         MUIA_Background,    MUII_ButtonBack,
  1121.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1122.                                     End,
  1123.  
  1124.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1125.                                         MUIA_Text_Contents,    "+",
  1126.                                         MUIA_Text_PreParse,    "\33c",
  1127.                                         MUIA_Background,    MUII_ButtonBack,
  1128.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1129.                                     End,
  1130.  
  1131.                         Child, InGads[GadNum++]    = TextObject, ButtonFrame,
  1132.                                         MUIA_Text_Contents,    "Z",
  1133.                                         MUIA_Text_PreParse,    "\33c",
  1134.                                         MUIA_Background,    MUII_ButtonBack,
  1135.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1136.                                     End,
  1137.  
  1138.                         Child, InGads[GadNum++]=    TextObject, ButtonFrame,
  1139.                                         MUIA_Text_Contents,    ")",
  1140.                                         MUIA_Text_PreParse,    "\33c",
  1141.                                         MUIA_Background,    MUII_ButtonBack,
  1142.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1143.                                     End,
  1144.  
  1145.                         Child, ExeObj        =    TextObject, ButtonFrame,
  1146.                                             MUIA_Text_Contents,    "Exec",
  1147.                                             MUIA_Text_PreParse,    "\33c",
  1148.                                             MUIA_Background,    MUII_ButtonBack,
  1149.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1150.                                         End,
  1151.                     End, // Input gadgets
  1152.                 End, // Third input area
  1153.             End, // VGroup
  1154.         End, // Main window
  1155.  
  1156.             // Now generate the Prefs window
  1157.  
  1158.         SubWindow, PrefsWindow = WindowObject,
  1159.                         MUIA_Window_Title,    "MUIProCalc Preferences",
  1160.                         MUIA_Window_ID,        'MPCP',
  1161.                         MUIA_Window_SizeGadget,    TRUE,
  1162.                         MUIA_Window_NoMenus,    TRUE,
  1163.                         MUIA_HelpNode,        NODE_PREFS,
  1164.  
  1165.             WindowContents, VGroup,
  1166.  
  1167.                 Child, ColGroup(2),
  1168.                     Child, VGroup, GroupFrameT("Window layout"),
  1169.                         MUIA_HelpNode,    NODE_LAYOUT,
  1170.  
  1171.                         Child, VSpace(0),
  1172.                         Child, HGroup,
  1173.  
  1174.                                 // Display functions gadget
  1175.  
  1176.                             Child, HGroup,
  1177.                                 Child, TextObject,
  1178.                                     MUIA_Text_PreParse,    "\033r",
  1179.                                     MUIA_Text_Contents,    "No Functions",
  1180.                                     MUIA_Text_HiChar,    'f',
  1181.                                 End,
  1182.                                 Child, HSpace(1),
  1183.                                 Child, DFuncObj    =    ImageObject, ImageButtonFrame,
  1184.                                                 MUIA_InputMode,        MUIV_InputMode_Toggle,
  1185.                                                 MUIA_Image_Spec,    MUII_CheckMark,
  1186.                                                 MUIA_Image_FreeVert,    TRUE,
  1187.                                                 MUIA_Selected,        NoFuncs,
  1188.                                                 MUIA_Background,    MUII_ButtonBack,
  1189.                                                 MUIA_ShowSelState,    FALSE,
  1190.                                                 MUIA_ControlChar,    'f',
  1191.                                                 MUIA_ExportID,        'FUNC',
  1192.                                             End,
  1193.                             End,
  1194.  
  1195.                                 // Display Inputs gadget
  1196.  
  1197.                             Child, HGroup,
  1198.                                 Child, TextObject,
  1199.                                     MUIA_Text_PreParse,    "\033r",
  1200.                                     MUIA_Text_Contents,    "No Input",
  1201.                                     MUIA_Text_HiChar,    'n',
  1202.                                 End,
  1203.                                 Child, HSpace(1),
  1204.                                 Child, DInObj    =    ImageObject, ImageButtonFrame,
  1205.                                                 MUIA_InputMode,        MUIV_InputMode_Toggle,
  1206.                                                 MUIA_Image_Spec,    MUII_CheckMark,
  1207.                                                 MUIA_Image_FreeVert,    TRUE,
  1208.                                                 MUIA_Selected,        NoInput,
  1209.                                                 MUIA_Background,    MUII_ButtonBack,
  1210.                                                 MUIA_ShowSelState,    FALSE,
  1211.                                                 MUIA_ControlChar,    'n',
  1212.                                                 MUIA_ExportID,        'INPU',
  1213.                                             End,
  1214.                             End,
  1215.                         End,
  1216.  
  1217.                             // Cycle Gadget for default type
  1218.  
  1219.                         Child, ColGroup(2),
  1220.                             Child, KeyLabel1("In/Out Order", 'O'),
  1221.                             Child, InOutObj    =    CycleObject, ButtonFrame,
  1222.                                             MUIA_Cycle_Active,    InOutLook,
  1223.                                             MUIA_Cycle_Entries,    InOutLookEntries,
  1224.                                             MUIA_ControlChar,    'o',
  1225.                                             MUIA_ExportID,        'ORDR',
  1226.                                         End,
  1227.                         End,
  1228.  
  1229.                         Child, VSpace(0),
  1230.  
  1231.                     End, // Layout gadgets
  1232.  
  1233.                     Child, VGroup, GroupFrameT("Output settings"),
  1234.                         MUIA_HelpNode,    NODE_OUTPUT,
  1235.  
  1236.                         Child, VSpace(0),
  1237.  
  1238.                             // Cycle Gadget for default type
  1239.  
  1240.                         Child, ColGroup(2),
  1241.                             Child, KeyLabel1("Base:", 'B'),
  1242.                             Child, TypeObj    =    CycleObject, ButtonFrame,
  1243.                                             MUIA_Cycle_Active,    IntType - ID_DECIMAL,
  1244.                                             MUIA_Cycle_Entries,    TypeEntries,
  1245.                                             MUIA_ControlChar,    'b',
  1246.                                             MUIA_ExportID,        'TYPE',
  1247.                                         End,
  1248.  
  1249.                             Child, KeyLabel1("Size:", 'z'),
  1250.                             Child, SizeObj    =    CycleObject, ButtonFrame,
  1251.                                             MUIA_Cycle_Active,    IntBase - ID_8BIT,
  1252.                                             MUIA_Cycle_Entries,    SizeEntries,
  1253.                                             MUIA_ControlChar,    'z',
  1254.                                             MUIA_ExportID,        'SIZE',
  1255.                                         End,
  1256.  
  1257.                             Child, KeyLabel1("Sign:", 'i'),
  1258.                             Child, SignObj    =    CycleObject, ButtonFrame,
  1259.                                             MUIA_Cycle_Active,    IntSign - ID_SIGNED,
  1260.                                             MUIA_Cycle_Entries,    SignEntries,
  1261.                                             MUIA_ControlChar,    'i',
  1262.                                             MUIA_ExportID,        'SIGN',
  1263.                                         End,
  1264.  
  1265.                             Child, KeyLabel1("Angle:", 'a'),
  1266.                             Child, AngleObj    =    CycleObject, ButtonFrame,
  1267.                                             MUIA_Cycle_Active,    IntAngle - ID_RAD,
  1268.                                             MUIA_Cycle_Entries,    AngleEntries,
  1269.                                             MUIA_ControlChar,    'a',
  1270.                                             MUIA_ExportID,        'ANGL',
  1271.                                         End,
  1272.                         End, // Cycle gadgets
  1273.  
  1274.                         Child, VSpace(0),
  1275.  
  1276.                     End, // Output settings
  1277.  
  1278.  
  1279.  
  1280.                     Child, VGroup, GroupFrameT("History settings"),
  1281.                         MUIA_HelpNode,    NODE_HISTORY,
  1282.  
  1283.                         Child, VSpace(0),
  1284.  
  1285.                             // Number of lines to buffer
  1286.  
  1287.                         Child, ColGroup(2),
  1288.                             Child, KeyLabel1("Lines:", 'L'),
  1289.                             Child, LinesObj    =    SliderObject,
  1290.                                             MUIA_Slider_Level,    HistLines,
  1291.                                             MUIA_Slider_Min,    1,
  1292.                                             MUIA_Slider_Max,    512,
  1293.                                             MUIA_ControlChar,    'l',
  1294.                                             MUIA_ExportID,        'LINE',
  1295.                                         End,
  1296.  
  1297.  
  1298.                             Child, KeyLabel1("Entries:", 'E'),
  1299.                             Child, LookObj    =    CycleObject, ButtonFrame,
  1300.                                             MUIA_Cycle_Active,    ListLook,
  1301.                                             MUIA_Cycle_Entries,    LookEntries,
  1302.                                             MUIA_ControlChar,    'e',
  1303.                                             MUIA_ExportID,        'LOOK',
  1304.                                         End,
  1305.                         End, // History col group
  1306.  
  1307.                         Child, VSpace(0),
  1308.  
  1309.                     End, // History settings
  1310.  
  1311.  
  1312.                     Child, VGroup, GroupFrameT("Misc"),
  1313.                         MUIA_HelpNode,    NODE_MISC,
  1314.  
  1315.                         Child, VSpace(0),
  1316.  
  1317.                             // Clear input checkbox
  1318.  
  1319.                         Child, HGroup,
  1320.                             Child, TextObject,
  1321.                                 MUIA_Text_PreParse,    "\033r",
  1322.                                 MUIA_Text_Contents,    "Clear input on exec",
  1323.                                 MUIA_Text_HiChar,    'r',
  1324.                             End,
  1325.                             Child, HSpace(1),
  1326.                             Child, ClearInObj =    ImageObject, ImageButtonFrame,
  1327.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  1328.                                             MUIA_Image_Spec,    MUII_CheckMark,
  1329.                                             MUIA_Image_FreeVert,    TRUE,
  1330.                                             MUIA_Selected,        ClearInput,
  1331.                                             MUIA_Background,    MUII_ButtonBack,
  1332.                                             MUIA_ShowSelState,    FALSE,
  1333.                                             MUIA_ControlChar,    'r',
  1334.                                             MUIA_ExportID,        'CLRI',
  1335.                                         End,
  1336.                         End, // Clear checkbox
  1337.  
  1338.                             // Flush memory gadget
  1339.  
  1340.                         Child, HGroup,
  1341.                             Child, TextObject,
  1342.                                 MUIA_Text_PreParse,    "\033r",
  1343.                                 MUIA_Text_Contents,    "Flush memory",
  1344.                                 MUIA_Text_HiChar,    'm',
  1345.                             End,
  1346.                             Child, HSpace(1),
  1347.                             Child, FlushObj    =    ImageObject, ImageButtonFrame,
  1348.                                             MUIA_InputMode,        MUIV_InputMode_Toggle,
  1349.                                             MUIA_Image_Spec,    MUII_CheckMark,
  1350.                                             MUIA_Image_FreeVert,    TRUE,
  1351.                                             MUIA_Selected,        FlushOnExit,
  1352.                                             MUIA_Background,    MUII_ButtonBack,
  1353.                                             MUIA_ShowSelState,    FALSE,
  1354.                                             MUIA_ControlChar,    'm',
  1355.                                             MUIA_ExportID,        'FLUS',
  1356.                                         End,
  1357.                         End, // Flush CheckBox
  1358.  
  1359.  
  1360.                             // Number of clipboard to use
  1361.  
  1362.                         Child, ColGroup(2),
  1363.                             Child, KeyLabel1("ClipUnit:", 'P'),
  1364.                             Child, ClipObj    =    SliderObject,
  1365.                                             MUIA_Slider_Level,    ClipUnit,
  1366.                                             MUIA_Slider_Min,    0,
  1367.                                             MUIA_Slider_Max,    255,
  1368.                                             MUIA_ControlChar,    'p',
  1369.                                             MUIA_ExportID,        'CLIP',
  1370.                                         End,
  1371.                         End, // Clipboard group
  1372.  
  1373.                         Child, VSpace(0),
  1374.  
  1375.                     End, // Misc Group
  1376.                 End, // Horizontal Groups
  1377.  
  1378.                     // Ok, Cancel, Save gadgets
  1379.  
  1380.                 Child, VGroup, GroupFrame,
  1381.                     Child, ColGroup(3), MUIA_Group_SameWidth, TRUE,
  1382.  
  1383.                             // Save Gadget
  1384.  
  1385.                         Child, SaveObj    =    TextObject, ButtonFrame,
  1386.                                         MUIA_Background,    MUII_ButtonBack,
  1387.                                         MUIA_Text_PreParse,    "\33c",
  1388.                                         MUIA_Text_Contents,    "Save",
  1389.                                         MUIA_Text_HiChar,    'S',
  1390.                                         MUIA_ControlChar,    's',
  1391.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1392.                                     End,
  1393.  
  1394.                             // Use Gadget
  1395.  
  1396.                         Child, OkObj    =    TextObject, ButtonFrame,
  1397.                                         MUIA_Background,    MUII_ButtonBack,
  1398.                                         MUIA_Text_PreParse,    "\33c",
  1399.                                         MUIA_Text_Contents,    "Use",
  1400.                                         MUIA_Text_HiChar,    'U',
  1401.                                         MUIA_ControlChar,    'u',
  1402.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1403.                                     End,
  1404.  
  1405.                             // Cancel Gadget
  1406.  
  1407.                         Child, CancelObj =    TextObject, ButtonFrame,
  1408.                                         MUIA_Background,    MUII_ButtonBack,
  1409.                                         MUIA_Text_PreParse,    "\33c",
  1410.                                         MUIA_Text_Contents,    "Cancel",
  1411.                                         MUIA_Text_HiChar,    'C',
  1412.                                         MUIA_ControlChar,    'c',
  1413.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1414.                                     End,
  1415.                     End, // ColGroup
  1416.                 End, // Use - Cancel gadgets
  1417.             End, // Prefs window contents
  1418.         End, // Prefs window
  1419.     End; // Application
  1420.  
  1421.     if(AppObject && InputGroup && OutputGroup)
  1422.     {
  1423.             // Set cycle chain for Prefs window
  1424.  
  1425.         DoMethod(PrefsWindow, MUIM_Window_SetCycleChain,
  1426.             DFuncObj,
  1427.             DInObj,
  1428.             InOutObj,
  1429.             TypeObj,
  1430.             SizeObj,
  1431.             SignObj,
  1432.             AngleObj,
  1433.             LinesObj,
  1434.             LookObj,
  1435.             ClearInObj,
  1436.             FlushObj,
  1437.             ClipObj,
  1438.             OkObj,
  1439.             SaveObj,
  1440.             CancelObj,
  1441.         NULL);
  1442.  
  1443.             // Set stuff for main window
  1444.  
  1445.         DoMethod(MainWindow, MUIM_Notify,
  1446.             MUIA_Window_CloseRequest,    TRUE,
  1447.             AppObject,            2,
  1448.             MUIM_Application_ReturnID,    ID_QUIT);
  1449.  
  1450.             //
  1451.             // Do the Gadgets
  1452.             //
  1453.  
  1454.             // Set ID for String-Input
  1455.  
  1456.         DoMethod(InputString, MUIM_Notify,
  1457.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1458.             AppObject,            2,
  1459.             MUIM_Application_ReturnID,    ID_INPUT);
  1460.  
  1461.             // Attach Output box to StringGadget
  1462.  
  1463.         set(InputString, MUIA_String_AttachedList, OutputBox);
  1464.  
  1465.             // Let the Cycle-Gadget talk to the Page-Group
  1466.  
  1467.         DoMethod(FunctionCycle, MUIM_Notify,
  1468.             MUIA_Cycle_Active, MUIV_EveryTime,
  1469.             PageObject, 3,
  1470.             MUIM_Set, MUIA_Group_ActivePage, MUIV_TriggerValue);
  1471.  
  1472.             // Reactivate input gadget
  1473.  
  1474.         DoMethod(FunctionCycle, MUIM_Notify,
  1475.             MUIA_Cycle_Active, MUIV_EveryTime,
  1476.             MainWindow, 3,
  1477.             MUIM_Set, MUIA_Window_ActiveObject, InputString);
  1478.  
  1479.  
  1480.             // Set up control gadgets to call Hook
  1481.  
  1482.         for(GadNum = 0; GadNum < 61; GadNum++)
  1483.         {
  1484.                 // First call the Hook when released
  1485.  
  1486.             DoMethod(InGads[GadNum], MUIM_Notify,
  1487.                 MUIA_Pressed,        FALSE,
  1488.                 AppObject,        3,
  1489.                 MUIM_CallHook,        &InsertHook, InGads[GadNum]);
  1490.  
  1491.                 // The reactivate the string gadget
  1492.  
  1493.             DoMethod(InGads[GadNum], MUIM_Notify,
  1494.                 MUIA_Pressed,        FALSE,
  1495.                 MainWindow,        3,
  1496.                 MUIM_Set,        MUIA_Window_ActiveObject, InputString);
  1497.         }
  1498.  
  1499.  
  1500.             // Return ID for Exe gadget
  1501.  
  1502.         DoMethod(ExeObj, MUIM_Notify,
  1503.             MUIA_Pressed,            FALSE,
  1504.             AppObject,            2,
  1505.             MUIM_Application_ReturnID,    ID_EXEC);
  1506.  
  1507.             // Return ID for CLR gadget
  1508.  
  1509.         DoMethod(ClrObj, MUIM_Notify,
  1510.             MUIA_Pressed,            FALSE,
  1511.             AppObject,            2,
  1512.             MUIM_Application_ReturnID,    ID_CLEAR);
  1513.  
  1514.             // Return ID for ACLR gadget
  1515.  
  1516.         DoMethod(AllClrObj, MUIM_Notify,
  1517.             MUIA_Pressed,            FALSE,
  1518.             AppObject,            2,
  1519.             MUIM_Application_ReturnID,    ID_ALLCLEAR);
  1520.  
  1521.  
  1522.  
  1523.  
  1524.             // Do the Prefs window
  1525.  
  1526.         DoMethod(PrefsWindow, MUIM_Notify,
  1527.             MUIA_Window_CloseRequest,    TRUE,
  1528.             AppObject,            2,
  1529.             MUIM_Application_ReturnID,    ID_PREFS_QUIT);
  1530.  
  1531.  
  1532.             // On OK, first save the prefs to env:
  1533.  
  1534.         DoMethod(OkObj, MUIM_Notify,
  1535.             MUIA_Pressed,            FALSE,
  1536.             AppObject,            2,
  1537.             MUIM_Application_Save,        MUIV_Application_Save_ENV);
  1538.  
  1539.             // Then signal the main program, that new prefs are available
  1540.  
  1541.         DoMethod(OkObj, MUIM_Notify,
  1542.             MUIA_Pressed,            FALSE,
  1543.             AppObject,            2,
  1544.             MUIM_Application_ReturnID,    ID_PREFS_NEW);
  1545.  
  1546.  
  1547.  
  1548.  
  1549.             // On SAVE, save both to env: and envarc:
  1550.  
  1551.         DoMethod(SaveObj, MUIM_Notify,
  1552.             MUIA_Pressed,            FALSE,
  1553.             AppObject,            2,
  1554.             MUIM_Application_Save, MUIV_Application_Save_ENV);
  1555.  
  1556.         DoMethod(SaveObj, MUIM_Notify,
  1557.             MUIA_Pressed,            FALSE,
  1558.             AppObject,            2,
  1559.             MUIM_Application_Save, MUIV_Application_Save_ENVARC);
  1560.  
  1561.             // New prefs available
  1562.  
  1563.         DoMethod(SaveObj, MUIM_Notify,
  1564.             MUIA_Pressed,            FALSE,
  1565.             AppObject,            2,
  1566.             MUIM_Application_ReturnID,    ID_PREFS_NEW);
  1567.  
  1568.  
  1569.  
  1570.             // On Cancel, simply close the window
  1571.  
  1572.         DoMethod(CancelObj, MUIM_Notify,
  1573.             MUIA_Pressed,            FALSE,
  1574.             AppObject,            2,
  1575.             MUIM_Application_ReturnID,    ID_PREFS_QUIT);
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.             // Load the settings
  1582.  
  1583.         DoMethod(AppObject, MUIM_Application_Load, MUIV_Application_Load_ENV);
  1584.  
  1585.  
  1586.             // Load defaults into variables
  1587.  
  1588.         get(DFuncObj, MUIA_Selected, &Dummy);
  1589.         NoFuncs = Dummy;
  1590.  
  1591.         get(DInObj, MUIA_Selected, &Dummy);
  1592.         NoInput = Dummy;
  1593.  
  1594.         get(InOutObj, MUIA_Cycle_Active, &Dummy);
  1595.         InOutLook = Dummy;
  1596.  
  1597.         get(TypeObj, MUIA_Cycle_Active, &Dummy);
  1598.         IntType    = RXIntType     = Dummy + ID_DECIMAL;
  1599.  
  1600.         get(SizeObj, MUIA_Cycle_Active, &Dummy);
  1601.         IntBase    = RXIntBase    = Dummy + ID_8BIT;
  1602.  
  1603.         get(SignObj, MUIA_Cycle_Active, &Dummy);
  1604.         IntSign    = RXIntSign    = Dummy + ID_SIGNED;
  1605.  
  1606.         get(AngleObj, MUIA_Cycle_Active, &Dummy);
  1607.         IntAngle = RXIntAngle    = Dummy + ID_RAD;
  1608.  
  1609.         get(LinesObj, MUIA_Slider_Level, &Dummy);
  1610.         HistLines = Dummy;
  1611.  
  1612.         get(LookObj, MUIA_Cycle_Active, &Dummy);
  1613.         ListLook = Dummy;
  1614.  
  1615.         get(ClearInObj, MUIA_Selected, &Dummy);
  1616.         ClearInput = Dummy;
  1617.  
  1618.         get(FlushObj, MUIA_Selected, &Dummy);
  1619.         FlushOnExit = Dummy;
  1620.  
  1621.         get(ClipObj, MUIA_Slider_Level, &Dummy);
  1622.         ClipUnit = Dummy;
  1623.  
  1624.             // Add in/out gadgets in correct order
  1625.  
  1626.         if(!InOutLook)
  1627.         {
  1628.             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  1629.             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  1630.         }
  1631.         else
  1632.         {
  1633.             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  1634.             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  1635.         }
  1636.  
  1637.             // Set cycle chain for main window _AFTER_ String and ListView have been added
  1638.  
  1639.         SetMainWinCycle();
  1640.  
  1641.             // Set listview look
  1642.  
  1643.         set(OutputBox, MUIA_List_Format, LookTemplates[ListLook]);
  1644.  
  1645.  
  1646.             // Add/Remove groups as requested
  1647.  
  1648.         if(NoFuncs)
  1649.             DoMethod(MainGroup, OM_REMMEMBER, FuncGroup, TAG_DONE);
  1650.  
  1651.         if(NoInput)
  1652.             DoMethod(MainGroup, OM_REMMEMBER, InGroup, TAG_DONE);
  1653.  
  1654.  
  1655.  
  1656.             // Set InputString to default object
  1657.  
  1658.         set(MainWindow, MUIA_Window_DefaultObject, InputString);
  1659.  
  1660.  
  1661.             // Open the main window
  1662.  
  1663.         set(MainWindow, MUIA_Window_Open, TRUE);
  1664.  
  1665.             // Now set Checkmarks
  1666.  
  1667.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, TRUE);
  1668.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, TRUE);
  1669.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, TRUE);
  1670.         DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, TRUE);
  1671.     }
  1672.     else
  1673.     {
  1674.         if(InputGroup)
  1675.             MUI_DisposeObject(InputGroup);
  1676.  
  1677.         if(OutputGroup)
  1678.             MUI_DisposeObject(OutputGroup);
  1679.     }
  1680.  
  1681.     return((BOOL)(AppObject && InputGroup && OutputGroup));
  1682. }
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689. /**********************************************************************/
  1690. /*                    Close the main window again                     */
  1691. /**********************************************************************/
  1692. static void CloseMainWin(void)
  1693. {
  1694.         // Dispose all Objects
  1695.  
  1696.     if(AppObject)
  1697.     {
  1698.         set(MainWindow, MUIA_Window_Open, FALSE);
  1699.         MUI_DisposeObject(AppObject);
  1700.     }
  1701.  
  1702.         // Dispose DiskObject
  1703.  
  1704.     if(DObject)
  1705.         FreeDiskObject(DObject);
  1706. }
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714. /**********************************************************************/
  1715. /*                      Format the output string                      */
  1716. /**********************************************************************/
  1717. BOOL FormatOutput(BOOL ReFormat)
  1718. {
  1719.     struct    ListStruct    NewEntry,
  1720.                 *NewEntryPtr;
  1721.     ULONG    ULong;
  1722.     BOOL    RetVal        = FALSE;
  1723.  
  1724.         // Set title of window first
  1725.  
  1726.     sprintf(Title, "MUIProCalc "REVISION" - "REVDATE" - %c%s%c %s", TypeChar[IntType - ID_DECIMAL], BaseStr[IntBase - ID_8BIT], SignChar[IntSign - ID_SIGNED], AngleStr[IntAngle - ID_RAD]);
  1727.     set(MainWindow, MUIA_Window_Title, Title);
  1728.  
  1729.         // Reformat entry ???
  1730.     if(!ReFormat)
  1731.     {
  1732.             // Get the Gadgets buffer
  1733.  
  1734.         get(InputString, MUIA_String_Contents, &ParseInput);
  1735.         strcpy(NewEntry.Input, ParseInput);
  1736.     }
  1737.     else
  1738.     {
  1739.         ULONG    NumEntries;
  1740.  
  1741.             // Get input from bottom entry within History
  1742.  
  1743.         get(OutputBox, MUIA_List_Entries, &NumEntries);
  1744.         DoMethod(OutputBox, MUIM_List_GetEntry, NumEntries - 1, &NewEntryPtr);
  1745.         NewEntry    = *NewEntryPtr;
  1746.         ParseInput    = NewEntry.Input;
  1747.     }
  1748.  
  1749.     if(strlen(ParseInput))
  1750.     {
  1751.             // Allocate memory pool for parsing
  1752.  
  1753.         if((ParsePool = DoCreatePool(MEMF_CLEAR, 8192, 2048)))
  1754.         {
  1755.                 // Reset scanner
  1756.  
  1757.             yychar            = -2;
  1758.             yynerrs            = 0;
  1759.             yy_init            = 1;
  1760.             yy_start        = 0;
  1761.             yyin = yyout        = NULL;
  1762.             yy_current_buffer    = NULL;
  1763.             ContainsUnDec        = FALSE;
  1764.  
  1765.                 // Do the parse
  1766.  
  1767.             yyparse();
  1768.  
  1769.                 // Delete pool again
  1770.  
  1771.             DoDeletePool(ParsePool);
  1772.  
  1773.             if(!yynerrs && !PError)
  1774.             {
  1775.                 RetVal    = TRUE;
  1776.  
  1777.                 switch(IntType)
  1778.                 {
  1779.                     case ID_DECIMAL :
  1780.                     {
  1781.                         if(!ContainsUnDec)
  1782.                         {
  1783.                             if((Value > 4294967295.0) || (Value < -4294967295.0) || ((Value < 1.0) && (Value > -1.0)))
  1784.                                 sprintf(NewEntry.Output, "%g ", Value);
  1785.                             else
  1786.                                 sprintf(NewEntry.Output, "%f ", Value);
  1787.                         }
  1788.                         else
  1789.                             sprintf(NewEntry.Output, "%f ", Value);
  1790.                         break;
  1791.                     }
  1792.  
  1793.                     case ID_HEXDECIMAL :
  1794.                     {
  1795.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  1796.                             strcpy(NewEntry.Output, "\0338Hex overflow");
  1797.                         else
  1798.                         {
  1799.                             sprintf(NewEntry.Output, "%f ", Value);
  1800.  
  1801.                                 // Now convert that output to a Long
  1802.  
  1803.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  1804.  
  1805.                                 // And reconvert it to hex output ;)
  1806.  
  1807.                             sprintf(NewEntry.Output, "$%x ", ULong);
  1808.                         }
  1809.                         break;
  1810.                     }
  1811.                     case ID_OCTAL :
  1812.                     {
  1813.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  1814.                             strcpy(NewEntry.Output, "\0338Octal overflow");
  1815.                         else
  1816.                         {
  1817.                             sprintf(NewEntry.Output, "%f ", Value);
  1818.  
  1819.                                 // First convert to Long
  1820.  
  1821.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  1822.  
  1823.                                 // Now conbert to octal
  1824.  
  1825.                             sprintf(NewEntry.Output, "\\%o ", ULong);
  1826.                         }
  1827.                         break;
  1828.                     }
  1829.                     case ID_BINARY :
  1830.                     {
  1831.                         char    AddOn[2];
  1832.                         int    i,
  1833.                             NumBits;
  1834.  
  1835.                         if((Value > 4294967295.0) || (Value < -4294967295.0))
  1836.                             strcpy(NewEntry.Output, "\0338Binary overflow");
  1837.                         else
  1838.                         {
  1839.                             sprintf(NewEntry.Output, "%f ", Value);
  1840.  
  1841.                             switch(IntBase)
  1842.                             {
  1843.                                 case ID_8BIT :
  1844.                                 {
  1845.                                     NumBits = 8;
  1846.                                     break;
  1847.                                 }
  1848.                                 case ID_16BIT :
  1849.                                 {
  1850.                                     NumBits = 16;
  1851.                                     break;
  1852.                                 }
  1853.                                 case ID_32BIT :
  1854.                                 {
  1855.                                     NumBits = 32;
  1856.                                     break;
  1857.                                 }
  1858.                             }
  1859.                                 // First convert to Long
  1860.  
  1861.                             stcd_l(NewEntry.Output, (LONG *)&ULong);
  1862.  
  1863.                                 // Set type identifier
  1864.  
  1865.                             strcpy(NewEntry.Output, "%");
  1866.  
  1867.                                 // Now convert to binary output
  1868.  
  1869.                             AddOn[1] = '\0';
  1870.                             for(i = NumBits - 1; i >= 0; i--)
  1871.                             {
  1872.                                 AddOn[0] = ((ULong & (1L << i)) ? (ULong & (1L << i)) - (1L << i) + '1' : '0');
  1873.                                 strcat(NewEntry.Output, AddOn);
  1874.  
  1875.                                     // 4 Bits done -> insert a space ;)
  1876.  
  1877.                                 if(!(i % 4))
  1878.                                     strcat(NewEntry.Output, " ");
  1879.                             }
  1880.                         }
  1881.                         break;
  1882.                     }
  1883.                 }
  1884.             }
  1885.             else
  1886.             {
  1887.                 if(PError == ERR_PARSE)
  1888.                     sprintf(NewEntry.Output, "\0338Syntax error in column %d", PColumn);
  1889.                 else if(PError == ERR_UNKNOWN_CHR)
  1890.                     sprintf(NewEntry.Output, "\0338Unknown char in column %d", PColumn);
  1891.                 else if(PError == ERR_DIVBY0)
  1892.                     sprintf(NewEntry.Output, "\0338Division by Zero in column %d", PColumn);
  1893.                 else
  1894.                     sprintf(NewEntry.Output, "\0338Overflow error in column %d", PColumn);
  1895.             }
  1896.  
  1897.                 // On "History-Overflow" remove top entry
  1898.  
  1899.             get(OutputBox, MUIA_List_Entries, &ULong);
  1900.             if(ULong > HistLines)
  1901.                 DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_First);
  1902.  
  1903.             NewEntryPtr    = &NewEntry;
  1904.             DoMethod(OutputBox, MUIM_List_Insert, &NewEntryPtr, 1, MUIV_List_Insert_Bottom);
  1905.             set(OutputBox, MUIA_List_Active, MUIV_List_Active_Bottom);
  1906.  
  1907.             if(ClearInput)
  1908.                 set(InputString, MUIA_String_Contents, "");
  1909.         }
  1910.         else
  1911.             MUI_Request(AppObject, MainWindow, NULL, NULL, "*Ok", "Sorry, no memory for parsing");
  1912.     }
  1913.  
  1914.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  1915.  
  1916.     return(RetVal);
  1917. }
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925. /**********************************************************************/
  1926. /*                  Insert Hook for function gadgets                  */
  1927. /**********************************************************************/
  1928. static ULONG    __saveds __asm InsertFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data)
  1929. {
  1930.     char    *Text;
  1931.  
  1932.         // Get Text of selected gadget
  1933.  
  1934.     get(*Data, MUIA_Text_Contents, &Text);
  1935.  
  1936.         // Insert text at cursor position
  1937.  
  1938.     InsertText(Text);
  1939.     return(0);
  1940. }
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947. /**********************************************************************/
  1948. /*        Hook-Function for generating a new entry for the LV         */
  1949. /**********************************************************************/
  1950. static ULONG    __saveds __asm DispConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data)
  1951. {
  1952.     struct    ListStruct    *New;
  1953.  
  1954.     if((New = AllocVec(sizeof(struct ListStruct), MEMF_CLEAR)))
  1955.     {
  1956.         *New    =    *Data;
  1957.         return((ULONG)New);
  1958.     }
  1959.  
  1960.     return(NULL);
  1961. }
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967. /**********************************************************************/
  1968. /*         Hook-Function for removing a new entry from the LV         */
  1969. /**********************************************************************/
  1970. static ULONG    __saveds __asm DispDestructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data)
  1971. {
  1972.     FreeVec(Data);
  1973.     return(0);
  1974. }
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981. /**********************************************************************/
  1982. /*                      Put pointers into array                       */
  1983. /**********************************************************************/
  1984. static ULONG    __saveds __asm DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ListStruct *Data)
  1985. {
  1986.     *array++    = Data->Input;
  1987.     *array        = Data->Output;
  1988.  
  1989.     return(NULL);
  1990. }
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997. /**********************************************************************/
  1998. /*        Insert a text-string at the current cursor-position         */
  1999. /**********************************************************************/
  2000. static void InsertText(char *NewText)
  2001. {
  2002.     char    NewBuff[258],
  2003.         *Text;
  2004.     ULONG    CursorPos;
  2005.  
  2006.         // No Error ?!?
  2007.  
  2008.     if(strncmp(NewText, "\0338", 2))
  2009.     {
  2010.             // Get current cursor Position within Input-String
  2011.  
  2012.         get(InputString, MUIA_String_BufferPos, &CursorPos);
  2013.         get(InputString, MUIA_String_Contents, &Text);
  2014.  
  2015.             // Copy to buffer, because the string`s contents may not be
  2016.             // directly altered
  2017.  
  2018.         strcpy(NewBuff, Text);
  2019.  
  2020.  
  2021.             // insert to cursor position
  2022.  
  2023.         if((strlen(NewBuff) + strlen(NewText)) < 256)
  2024.             strins(&NewBuff[CursorPos], NewText);
  2025.         else
  2026.             DisplayBeep(NULL);
  2027.  
  2028.             // Set new string for String-Gadget
  2029.  
  2030.         set(InputString, MUIA_String_Contents, NewBuff);
  2031.     }
  2032.  
  2033.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2034. }
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040. /**********************************************************************/
  2041. /*          Write the given entry to the specified clipboard          */
  2042. /**********************************************************************/
  2043. static void WriteClip(char *Entry)
  2044. {
  2045.     struct    IFFHandle    *Handle;
  2046.     BOOL    Ok = FALSE;
  2047.  
  2048.         // Length > 0 ???
  2049.  
  2050.     if(strlen(Entry) && strncmp(Entry, "\0338", 2))
  2051.     {
  2052.             // Try to obtain an IFF Handle
  2053.  
  2054.         if((Handle = AllocIFF()))
  2055.         {
  2056.                 // Open needed clipboard unit
  2057.  
  2058.             if((Handle->iff_Stream = (ULONG)OpenClipboard(ClipUnit)))
  2059.             {
  2060.                 InitIFFasClip(Handle);
  2061.  
  2062.                     // Open Handle for write access
  2063.  
  2064.                 if(!OpenIFF(Handle, IFFF_WRITE))
  2065.                 {
  2066.                         // Push first chunk (FORM)
  2067.  
  2068.                     if(!PushChunk(Handle, ID_FTXT, ID_FORM, IFFSIZE_UNKNOWN))
  2069.                     {
  2070.                             // Push chars chunk
  2071.  
  2072.                         if(!PushChunk(Handle, 0, ID_CHRS, IFFSIZE_UNKNOWN))
  2073.                         {
  2074.                                 // Write data to clipboard
  2075.  
  2076.                             if(WriteChunkBytes(Handle, Entry, strlen(Entry)) == strlen(Entry))
  2077.                             {
  2078.                                     // Pop contents chunk
  2079.  
  2080.                                 if(!PopChunk(Handle))
  2081.                                     Ok = TRUE;
  2082.                             }
  2083.                         }
  2084.  
  2085.                             // Pop FORM chunk
  2086.  
  2087.                         if(Ok)
  2088.                             PopChunk(Handle);
  2089.                     }
  2090.  
  2091.                         // Close IFF Handle
  2092.  
  2093.                     CloseIFF(Handle);
  2094.                 }
  2095.  
  2096.                     // Close Clipboard again
  2097.  
  2098.                 CloseClipboard((struct ClipboardHandle *)Handle->iff_Stream);
  2099.             }
  2100.  
  2101.                 // Free IFF Handle
  2102.  
  2103.             FreeIFF(Handle);
  2104.         }
  2105.     }
  2106.  
  2107.     set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2108. }
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115. /**********************************************************************/
  2116. /*                This is the main controlling routine                */
  2117. /**********************************************************************/
  2118. static void HandleInputs(void)
  2119. {
  2120.     ULONG    MySig, ReturnID;
  2121.     BOOL    GoOn    = TRUE;
  2122.  
  2123.     while(GoOn)
  2124.     {
  2125.         switch(ReturnID = DoMethod(AppObject, MUIM_Application_Input, &MySig))
  2126.         {
  2127.                 // Input done ;)
  2128.  
  2129.             case ID_INPUT :
  2130.             {
  2131.                 FormatOutput(FALSE);
  2132.                 break;
  2133.             }
  2134.  
  2135.                 // Translate input
  2136.  
  2137.             case ID_EXEC :
  2138.             {
  2139.                 FormatOutput(FALSE);
  2140.                 break;
  2141.             }
  2142.  
  2143.                 // Clear input
  2144.  
  2145.             case ID_CLEAR :
  2146.             {
  2147.                 set(InputString, MUIA_String_Contents, "");
  2148.                 FormatOutput(FALSE);
  2149.                 break;
  2150.             }
  2151.  
  2152.                 // Clear input AND Memory
  2153.  
  2154.             case ID_ALLCLEAR :
  2155.             {
  2156.                 XMem = YMem = ZMem = 0.0;
  2157.                 set(InputString, MUIA_String_Contents, "");
  2158.                 FormatOutput(FALSE);
  2159.                 break;
  2160.             }
  2161.  
  2162.                 // Open Prefs window
  2163.  
  2164.             case ID_PREFS :
  2165.             {
  2166.                 set(PrefsWindow, MUIA_Window_Open, TRUE);
  2167.                 break;
  2168.             }
  2169.  
  2170.                 // Display About
  2171.  
  2172.             case ID_ABOUT :
  2173.             {
  2174.                 MUI_Request(AppObject, MainWindow, 0, NULL, "*Okay",
  2175.                     "\033cMUIProCalc v%ld.%ld, written by Kai Iske, GiftWare\n\n"
  2176.                     "\0338Powerful calculator, also suited for programmers\n\n"
  2177.                     "\033l\0332To contact me, write to:\n\033c"
  2178.                     "Kai Iske, Brucknerstrasse 18, 63452 Hanau, Germany\n"
  2179.                     "Tel.: +49-(0)6181-850181\n\n"
  2180.                     "\033lor use electronical mail\n\033c"
  2181.                     "kai@iske.adsp.sub.org\n"
  2182.                     "iske@informatik.uni-frankfurt.de\n"
  2183.                     "Kai Iske, 2:244/6302.11\n"
  2184.                     "KAI@SWEET.ZER\n\n"
  2185.                     "\033c\0332MUIProCalc is a MUI-Application\n"
  2186.                     "MUI is ⌐ Stefan Stuntz",
  2187.                     VERNUM, REVNUM, TAG_DONE);
  2188.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2189.                 break;
  2190.             }
  2191.                 // Quit the program
  2192.  
  2193.             case ID_QUIT :
  2194.             case MUIV_Application_ReturnID_Quit :
  2195.             {
  2196.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  2197.                 GoOn = FALSE;
  2198.                 break;
  2199.             }
  2200.  
  2201.                 // Pick left entry from History ???
  2202.  
  2203.             case ID_PICKLEFT :
  2204.             {
  2205.                 struct    ListStruct    *LSV;
  2206.                 ULONG    ClickCol;
  2207.  
  2208.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2209.  
  2210.                 if(LSV)
  2211.                 {
  2212.                     if(ListLook == 0 || ListLook == 2)
  2213.                         ClickCol = 0;
  2214.                     else if(ListLook == 1 || ListLook == 3)
  2215.                         ClickCol = 1;
  2216.  
  2217.                     if(!ClickCol)
  2218.                         InsertText(LSV->Input);
  2219.                     else
  2220.                         InsertText(LSV->Output);
  2221.                 }
  2222.                 break;
  2223.             }
  2224.  
  2225.                 // Pick right entry from History ???
  2226.  
  2227.             case ID_PICKRIGHT :
  2228.             {
  2229.                 struct    ListStruct    *LSV;
  2230.                 ULONG    ClickCol;
  2231.  
  2232.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2233.  
  2234.                 if(LSV)
  2235.                 {
  2236.                     if(ListLook == 0 || ListLook == 3)
  2237.                         ClickCol = 1;
  2238.                     else if(ListLook == 1 || ListLook == 2)
  2239.                         ClickCol = 0;
  2240.  
  2241.                     if(!ClickCol)
  2242.                         InsertText(LSV->Input);
  2243.                     else
  2244.                         InsertText(LSV->Output);
  2245.                 }
  2246.                 break;
  2247.             }
  2248.  
  2249.                 // Copy left history entry to clipboard
  2250.  
  2251.             case ID_CLIPCUTLEFT :
  2252.             {
  2253.                 struct    ListStruct    *LSV;
  2254.                 ULONG    ClickCol;
  2255.  
  2256.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2257.  
  2258.                 if(LSV)
  2259.                 {
  2260.                     if(ListLook == 0 || ListLook == 2)
  2261.                         ClickCol = 0;
  2262.                     else if(ListLook == 1 || ListLook == 3)
  2263.                         ClickCol = 1;
  2264.  
  2265.                     if(!ClickCol)
  2266.                         WriteClip(LSV->Input);
  2267.                     else
  2268.                         WriteClip(LSV->Output);
  2269.                 }
  2270.  
  2271.                 break;
  2272.             }
  2273.  
  2274.                 // Copy left history entry to clipboard
  2275.  
  2276.             case ID_CLIPCUTRIGHT :
  2277.             {
  2278.                 struct    ListStruct    *LSV;
  2279.                 ULONG    ClickCol;
  2280.  
  2281.                 DoMethod(OutputBox, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &LSV);
  2282.  
  2283.                 if(LSV)
  2284.                 {
  2285.                     if(ListLook == 0 || ListLook == 3)
  2286.                         ClickCol = 1;
  2287.                     else if(ListLook == 1 || ListLook == 2)
  2288.                         ClickCol = 0;
  2289.  
  2290.                     if(!ClickCol)
  2291.                         WriteClip(LSV->Input);
  2292.                     else
  2293.                         WriteClip(LSV->Output);
  2294.                 }
  2295.  
  2296.                 break;
  2297.             }
  2298.  
  2299.                 // Check Output Type
  2300.  
  2301.             case ID_DECIMAL :
  2302.             case ID_HEXDECIMAL :
  2303.             case ID_OCTAL :
  2304.             case ID_BINARY :
  2305.             {
  2306.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, FALSE);
  2307.                 IntType    = ReturnID;
  2308.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntType, TRUE);
  2309.                 FormatOutput(TRUE);
  2310.                 break;
  2311.             }
  2312.  
  2313.                 // Check for Bases
  2314.  
  2315.             case ID_8BIT :
  2316.             case ID_16BIT :
  2317.             case ID_32BIT :
  2318.             {
  2319.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, FALSE);
  2320.                 IntBase    = ReturnID;
  2321.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntBase, TRUE);
  2322.                 FormatOutput(TRUE);
  2323.                 break;
  2324.             }
  2325.  
  2326.                 // Check for Signs
  2327.  
  2328.             case ID_SIGNED :
  2329.             case ID_UNSIGNED :
  2330.             {
  2331.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, FALSE);
  2332.                 IntSign    = ReturnID;
  2333.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntSign, TRUE);
  2334.                 FormatOutput(TRUE);
  2335.                 break;
  2336.             }
  2337.  
  2338.                 // Check angle
  2339.  
  2340.             case ID_RAD :
  2341.             case ID_DEG :
  2342.             {
  2343.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, FALSE);
  2344.                 IntAngle    = ReturnID;
  2345.                 DoMethod(MainWindow, MUIM_Window_SetMenuCheck, (ULONG)IntAngle, TRUE);
  2346.                 FormatOutput(TRUE);
  2347.                 break;
  2348.             }
  2349.  
  2350.  
  2351.  
  2352.  
  2353.                 //
  2354.                 // This is for the Prefs window
  2355.                 //
  2356.  
  2357.                 // Close prefs window
  2358.  
  2359.             case ID_PREFS_QUIT :
  2360.             {
  2361.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  2362.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2363.  
  2364.                     // Reset preferences
  2365.  
  2366.                 set(InOutObj, MUIA_Cycle_Active, InOutLook);
  2367.                 set(DFuncObj, MUIA_Selected, NoFuncs);
  2368.                 set(DInObj, MUIA_Selected, NoInput);
  2369.                 set(TypeObj, MUIA_Cycle_Active, (ULONG)IntType);
  2370.                 set(SizeObj, MUIA_Cycle_Active, (ULONG)IntBase);
  2371.                 set(SignObj, MUIA_Cycle_Active, (ULONG)IntSign);
  2372.                 set(AngleObj, MUIA_Cycle_Active, (ULONG)IntAngle);
  2373.                 set(LinesObj, MUIA_Slider_Level, (ULONG)HistLines);
  2374.                 set(LookObj, MUIA_Cycle_Active, (ULONG)ListLook);
  2375.                 set(ClearInObj, MUIA_Selected, (ULONG)ClearInput);
  2376.                 set(FlushObj, MUIA_Selected, (ULONG)FlushOnExit);
  2377.                 set(ClipObj, MUIA_Slider_Level, (ULONG)ClipUnit);
  2378.                 break;
  2379.             }
  2380.  
  2381.             case ID_PREFS_NEW :
  2382.             {
  2383.                 ULONG    NewInOut, NewFunc, NewInput, NewLook;
  2384.  
  2385.                     // Get clear flag
  2386.  
  2387.                 get(ClearInObj, MUIA_Selected, &NewFunc);
  2388.                 ClearInput = NewFunc;
  2389.  
  2390.                     // Get flush flag
  2391.  
  2392.                 get(FlushObj, MUIA_Selected, &NewFunc);
  2393.                 FlushOnExit = NewFunc;
  2394.  
  2395.                     // Get ClipBoard unit
  2396.  
  2397.                 get(ClipObj, MUIA_Slider_Level, &NewFunc);
  2398.                 ClipUnit = NewFunc;
  2399.  
  2400.                 set(PrefsWindow, MUIA_Window_Open, FALSE);
  2401.                 get(LinesObj, MUIA_Slider_Level, &NewFunc);
  2402.                 HistLines = NewFunc;
  2403.  
  2404.                     // Rebuild History
  2405.  
  2406.                 get(OutputBox, MUIA_List_Entries, &NewInput);
  2407.                 while(NewInput > HistLines)
  2408.                 {
  2409.                     DoMethod(OutputBox, MUIM_List_Remove, MUIV_List_Remove_First);
  2410.                     NewInput--;
  2411.                 }
  2412.  
  2413.                     // Check for changes on layout
  2414.  
  2415.                 get(InOutObj, MUIA_Cycle_Active, &NewInOut);
  2416.                 get(DFuncObj, MUIA_Selected, &NewFunc);
  2417.                 get(DInObj, MUIA_Selected, &NewInput);
  2418.                 get(LookObj, MUIA_Cycle_Active, &NewLook);
  2419.  
  2420.                 if((NewInOut != InOutLook) || (NewFunc != NoFuncs) || (NewInput != NoInput))
  2421.                 {
  2422.                         // Close main window first
  2423.  
  2424.                     set(MainWindow, MUIA_Window_Open, FALSE);
  2425.  
  2426.                         // Rearrange input output order
  2427.  
  2428.                     if(NewInOut != InOutLook)
  2429.                     {
  2430.                         InOutLook = NewInOut;
  2431.  
  2432.                             // Remove groups first
  2433.  
  2434.                         DoMethod(InOutGroup, OM_REMMEMBER, InputGroup);
  2435.                         DoMethod(InOutGroup, OM_REMMEMBER, OutputGroup);
  2436.  
  2437.                             // Readd groups
  2438.  
  2439.                         if(!InOutLook)
  2440.                         {
  2441.                             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  2442.                             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  2443.                         }
  2444.                         else
  2445.                         {
  2446.                             DoMethod(InOutGroup, OM_ADDMEMBER, OutputGroup);
  2447.                             DoMethod(InOutGroup, OM_ADDMEMBER, InputGroup);
  2448.                         }
  2449.  
  2450.                             // Reset cycle order
  2451.  
  2452.                         SetMainWinCycle();
  2453.                     }
  2454.  
  2455.                         // First remove existent groups from main group
  2456.  
  2457.                     if(!NoFuncs)
  2458.                         DoMethod(MainGroup, OM_REMMEMBER, FuncGroup);
  2459.  
  2460.                     if(!NoInput)
  2461.                         DoMethod(MainGroup, OM_REMMEMBER, InGroup);
  2462.  
  2463.                         // Add Function group when needed
  2464.  
  2465.                     NoFuncs = NewFunc;
  2466.                     if(!NoFuncs)
  2467.                         DoMethod(MainGroup, OM_ADDMEMBER, FuncGroup);
  2468.  
  2469.                         // Add Input group when needed
  2470.  
  2471.                     NoInput = NewInput;
  2472.                     if(!NoInput)
  2473.                         DoMethod(MainGroup, OM_ADDMEMBER, InGroup);
  2474.  
  2475.  
  2476.                         // Reopen window
  2477.  
  2478.                     set(MainWindow, MUIA_Window_Open, TRUE);
  2479.                 }
  2480.  
  2481.                 if(NewLook != ListLook)
  2482.                 {
  2483.                             // Set listview look
  2484.  
  2485.                     ListLook = NewLook;
  2486.                     set(OutputBox, MUIA_List_Format, LookTemplates[ListLook]);
  2487.                 }
  2488.  
  2489.                 set(MainWindow, MUIA_Window_Activate, TRUE);
  2490.                 set(MainWindow, MUIA_Window_ActiveObject, InputString);
  2491.                 break;
  2492.             }
  2493.         }
  2494.  
  2495.         if(GoOn && MySig)
  2496.             Wait(MySig);
  2497.     }
  2498. }
  2499.